package com.xyy.jd_clund.config;

import com.kingdee.service.ApiClient;
import com.kingdee.service.Configuration;
import com.xyy.jd_clund.utils.TokenCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class ClientApiConfig {
    @Value("${kingdee.client_id}")
    private String clientId;

    @Value("${kingdee.client_secret}")
    private String clientSecret;

    @PostConstruct
    public void init() {
        ApiClient defaultApiClient = Configuration.getDefaultApiClient();
        defaultApiClient.setClientId(clientId);
        defaultApiClient.setClientSecret(clientSecret);
        defaultApiClient.setAppToken(TokenCache.getToken());

    }
}
